<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
        <script>
                // HTML5和css3 一般是ie9 及以上的浏览器支持

                // localStorage和sessionStorage 兼容ie8浏览器
                // localStorage 的数据存储量大5Mb左右
                // localStoage 不能设置过期时间  需要手动清除
                
                // 1.设置localStorage
                // localStorage.属性=属性值;
                localStorage.stuname="男神";
                localStorage.setItem("nvname","女神");
                localStorage.arr=["蔡徐坤","吴亦凡","赵本山","姚尚"];
                localStorage.obj={
                    name:"罗志祥",
                    age:38,
                    aihao:"广泛"
                }
                // 2.获取localStroage 
                // localStorage.属性
                // localStorage.getItem("属性")
                console.log(localStorage.stuname)
                console.log( localStorage.getItem("nvname"))
                console.log(localStorage.arr)
                console.log(localStorage.getItem("obj"))
                
                // 3. 删除localStorage
                //localStroage.removeItem("属性")
                localStorage.removeItem("nvname")

                // 4.清空localStroage 
                // localStorage.clear()
                
                //5.根据索引（下标），获取存储时候的属性名，参数（index） 
            
                console.log(localStorage.key(2)) //arr
                
                


        </script>
</body>
</html>